﻿<include file="Public/header"/>
<include file="Public/menu"/>
<div class="page-content">
	<div class="page-header">
		<h1>
			标签
			<small>
				<i class="icon-double-angle-right"></i>
				浏览标签
			</small>
		</h1>
	</div>
	<!-- /.page-header -->
	<!-- PAGE CONTENT BEGINS -->
	<div class="row">
		<div class="col-xs-12">
			<div class="row">
				<div class="tabbable">
					<ul class="nav nav-tabs" id="myTab">
						<li class="active">
							<a>
								<i class="green icon-home bigger-110"></i>
								浏览标签
							</a>
						</li>
						<li>
							<a  href="{:U('Tag/add')}">
								<i class="green icon-edit bigger-110"></i>
								添加标签
							</a>
						</li>
					</ul>
					<div class="tab-content col-xs-10">
						<div  class="tab-pane in active">
						<div class="table-responsive">
						<table id="sample-table-1" class="table table-striped table-bordered table-hover">
						<thead>
						<tr>
							<th class="center">ID</th>
							<th>标签名</th>
							<th class="center">操作</th>
						</tr>
						</thead>

						<tbody>
						<foreach name="list" item="v">
						<tr>
							<td class="center">{$v.id}</td>
							<td>{$v.tagname}</td>
							<td class="col-xs-3">
								<div class="visible-md visible-lg hidden-sm hidden-xs btn-group">
									<button class="btn btn-xs btn-inverse" title="添加子标签" id="addChild"
											data-url="{:U('Tag/add?id='.$v['id'])}">
										<i class="icon-bookmark-empty bigger-120"></i>
										添加子标签
									</button>
									<button class="btn btn-xs btn-info" title="编辑" id="edit" data-url="{:U('Tag/edit?id='.$v['id'])}">
										<i class="icon-edit bigger-120"></i>
										编辑
									</button>
									<button class="btn btn-xs btn-danger" title="删除" id="del" data-id="{$v.id}">
										<i class="icon-trash bigger-120"></i>
										删除
									</button>
								</div>
							</td>
						</tr>
						</foreach>
						</tbody>
						</table>
						</div><!-- /.table-responsive -->
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!-- PAGE CONTENT END -->
</div>
</div>
</div>
<script>
	seajs.use(['$','bootbox'],function($){
		$("button#edit,button#addChild").click(function(){
			window.location.href = $(this).attr("data-url");
		})
		$("button#del").click(function(){
			if(confirm("确定要删除该标签吗？")){
				$id = $(this).attr("data-id");
				$.ajax({
					url:"{:U('Tag/delete')}",
					data:{id:$id},
					type:"get",
					success:function(data){
						if(data.status > 0 ){
							bootbox.confirm(data.info,function(result){
								if(result){
									window.location.reload();
									return false;
								}
							});
						}else{
							bootbox.alert({
								message:data.info,
								title: "提示信息"
							});
							return false;
						}
					}
				})
			}
		});

	})
</script>
<include file="Public/footer"/>

